﻿<script type="text/javascript">

    var ParamList = {};
    ParamList.DelUrl = "";
    ParamList.EditUrl = "";

    ParamList.DeleteFormatter = function (value, rec, index) {
        if (rec.StateID == 1)
            return "";
        return "<a  class='btn-del' href='" + ParamList.DelUrl + "?parameterID=" + rec.UID + "' onclick='ParamList.Delete(this); return false;' >删除</a>";
    }

    ParamList.EditFormatter = function (value, rec, index) {
        return "<a  class='btn-edit' href='" + $(".tabs-panels .panel:visible").find("#editParamUrl").val() + "?parameterID=" + rec.UID + "' onclick='ParamList.Edit(this); return false;' >修改</a>";
    }

    ParamList.StateFormatter = function (value, rec, index) {
        return value == "Enable" ? "启用" : "禁用";
    }

    ParamList.Delete = function (e) {
        if (!confirm("确认要删除吗？"))
            return;
        $.post($(e).attr("href"), function (data) {
            if (data.IsOK) {
                $('#@("tbParamList_" + ViewBag.TypeID)').datagrid("reload");
            }
            else
                alert(data.Description);
        });
    }
    ParamList.Create = function (e) {
        $.createWin({ url: e.href, width: 600, height: 350, title: '添加普通参数' });
        return false;
    }

    ParamList.Edit = function (e) {
        $.createWin({ url: e.href, width: 600, height: 350, title: '修改普通参数' });
        return false;
    }

    ParamList.Back = function (e) {
        Common.CloseTab();
    }

    $(document).ready(function () {
        //参数初始化
        ParamList.DelUrl = $(".tabs-panels .panel:visible").find("#delParamUrl").val();

        //呈现列表数据
        $('#@("tbParamList_" + ViewBag.TypeID)').datagrid({ pagination: true });
    });

</script>
@Html.Hidden("delParamUrl", Url.Action("DeleteParam", new { id = ViewBag.TypeID }))
@Html.Hidden("editParamUrl", Url.Action("EditParam", new { id = ViewBag.TypeID }))
<div class="tt-attach">
    <ul class="op">
        <li>
            @Html.ActionLink("返回分类列表", "List", null, new { onclick = "ParamList.Back(this); return false;", @class = "btn btn-dirleft" })
        </li>
        <li>
            @Html.ActionLink("添加普通参数", "CreateParam", new { id = ViewBag.TypeID }, new { onclick = "ParamList.Create(this); return false;", @class = "btn btn-insertarticle" })
        </li>
    </ul>
</div>
<div style="padding: 5px 10px;">
    <table id="@("tbParamList_" + ViewBag.TypeID)" style="height: auto" striped="true" nowrap="false" rownumbers="true" fitColumns="true" title="" iconcls="icon-edit"
    singleselect="true" idfield="UID" url="@Url.Action("ParamListData", new { id = ViewBag.TypeID })">
        <thead>
            <tr>
                <th field="ParameterName" width="200">
                    参数名称
                </th>
                <th field="ParameterCode" formatter="ParamList.PriorityFormatter" width="200">
                    参数代码
                </th>
                <th field="ParameterCodeID" width="60" align="center">
                    参数标识
                </th>
                <th field="Remark" width="150">
                    备注
                </th>
                <th field="StateCode" formatter="ParamList.StateFormatter" width="50" align="center">
                    状态
                </th>
                <th field="修改" width="50" formatter="ParamList.EditFormatter" align="center">
                    修改
                </th>
                <th field="删除" width="50" formatter="ParamList.DeleteFormatter" align="center">
                    删除
                </th>
            </tr>
        </thead>
    </table>
</div>
